package com.linux.huhx.thread2;

public class InterruptTest {
    public static void main(String[] args) throws Exception {
        MyThread1 myThread1 = new MyThread1();
        myThread1.start();

        myThread1.interrupt();
        System.out.println("isInterrupted is " + myThread1.isInterrupted()); // true
        System.out.println("isInterrupted is " + myThread1.interrupted()); // false
    }

    static class MyThread1 extends Thread {
        @Override
        public void run() {
            while (true) {
                if (Thread.interrupted()) {
                    System.out.println("break");
                    break;
                }
                System.out.println("count " + Thread.currentThread().isInterrupted()); // count false
            }
        }
    }
}
